package com.aigao.golf.common.config

import org.springframework.context.EnvironmentAware
import org.springframework.core.env.Environment

object ParamFactory : EnvironmentAware{




    override fun setEnvironment(environment: Environment) {
        println("environment:   " + environment.getProperty("runtime"))
        currRt = environment.getProperty("runtime")
    }

    private const val DEV = "dev"
    private const val TEST = "test"
    private const val PRO = "pro"

    private lateinit var currRt : String

    fun fastdfsHttpSecretKey() = when(currRt){
        DEV ->"FastDFS1234567890"
        TEST ->"FastDFS1234567890"
        else ->"FastDFS1234567890"
    }

    fun fastdfsTrackerServers() = when(currRt){
        DEV -> "192.168.1.117:22122"
        TEST -> "192.168.1.117:22122"
        else -> "192.168.1.117:22122"
    }



    fun connectUrl() = when(currRt){
        DEV -> "jdbc:mysql://192.168.1.115:3306/golf?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&useSSL=false"
        TEST -> "jdbc:mysql://118.31.250.179:3306/golf?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&useSSL=false"
        else -> "jdbc:mysql://192.168.1.115:3306/golf?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&useSSL=false"
    }

    fun username() = when(currRt){
        DEV -> "root"
        TEST -> "root"
        else -> "root"
    }


    fun password() = when(currRt){
        DEV -> "qkjr_420"
        TEST -> "qkjr_420"
        else -> "qkjr_420"
    }



}
